package com.lxyk.dao.user;

import com.lxyk.domain.SysRole;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface RoleDao {
    //根据用户id查询角色列表
    @Select("SELECT r.id, r.role_name roleName, r.role_desc roleDesc " +
            "FROM sys_role r, sys_user_role ur " +
            "WHERE r.id=ur.rid AND ur.uid=#{uid}")
    public List<SysRole> findByUid(Integer uid);

    //保存角色
    @Insert("insert into sys_role (role_name, role_desc) values (#{roleName}, #{roleDesc})")
    public void save(SysRole role);

    //查询所有角色
    @Select("select id, role_name roleName, role_desc roleDesc from sys_role")
    public List<SysRole> findAll();

    //删除角色
    @Delete("delete from sys_role where id=#{id}")
    public void deleteById(Integer id);
}
